package com.red.wood.module.evalMol.dao.Impl;

import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import com.red.wood.common.springjdbc.CommonDao;
import com.red.wood.module.evalMol.dao.IcpMolDao;

@Repository
public class IcpMolDaoImpl implements IcpMolDao{

	@Autowired
	private CommonDao dao;
	@Autowired
	private JdbcTemplate jdbcTemplate;
	
	@Override
	public void addList(List<Map<String, Object>> paramList) {
		String columns = "singleTaskId,domain,icp";
		String insertSql = "insert into t_eval_repY_icpInfoMol(singleTaskId,domain,icp) values (?, ?, ?)";
		dao.insertBatchTableData(paramList, insertSql, columns);
	}

	@Override
	public void delete(String singleTaskId) {
		StringBuffer sql = new StringBuffer();
		if(StringUtils.isNotBlank(singleTaskId)){
			sql.append("delete from t_eval_repY_icpInfoMol where singleTaskId = "+ singleTaskId);
		}
		dao.deleteTableData(sql.toString());
	}

	@Override
	public List<Map<String, Object>> getBySingleTaskId(String singleTaskId) {
		if(StringUtils.isNotBlank(singleTaskId)){
			String sql = "select singleTaskId,domain,icp from t_eval_repY_icpInfoMol where singleTaskId= " + singleTaskId;
			List<Map<String,Object>> dataList =  jdbcTemplate.queryForList(sql.toString());
			return dataList;
		} 
		return null;
	}
	
}
